import httpFetch from 'share/httpFetch'
import config from 'config'
import {messages} from "share/common";
import {message} from "antd/lib/index";

export default {

  //查看报表列表
  getReportList(page, pageSize,params) {
    let url = `${config.baseUrl}/api/report/heads/company?&page=${page}&size=${pageSize}`;
    for (let paramsName in params) {
      url += params[paramsName] ? `&${paramsName}=${params[paramsName]}` : '';
    }
    return httpFetch.get(url)
  },

  //新建 报表副本
  createCopyReport(reportHeadOID) {
    let url = `${config.baseUrl}/api/report/heads/create/report/line`;
    return httpFetch.post(url,reportHeadOID);
  },

  //更新 单条分配信息
  updateCopyReport(copyReportData) {
    let url = `${config.baseUrl}/api/report/line`;
    return httpFetch.put(url,copyReportData);
  },

  //保存 新建 单条分配信息
  saveCopyReport(copyReportData) {
    let url = `${config.baseUrl}/api/report/lines`;
    return httpFetch.post(url,copyReportData);
  },

  //删除当前 单条 报表副本 信息
  deleteAllotReportDetail(reportLineOID) {
    let url = `${config.baseUrl}/api/report/line/${reportLineOID}`;
    return httpFetch.delete(url);
  },

  //查看某报表分配列表
  getReportDetailList(page, pageSize,params) {
    let url = `${config.baseUrl}/api/report/lines/page?&page=${page}&reportHeadOID=${params.reportHeadOID}&size=${pageSize}`;
    return httpFetch.get(url)
  },

  //查看单条报表分配所属报表详情
  getReportDetail(reportHeadOID) {
    let url = `${config.baseUrl}/api/report/heads/company/${reportHeadOID}`;
    return httpFetch.get(url)
  },

  //查看 单条 报表副本分配所属报表详情
  getCopyReportDetail(reportLineOID) {
    let url = `${config.baseUrl}/api/report/line/${reportLineOID}`;
    return httpFetch.get(url)
  },

  //查看分配人员详情
  getDistributionPeopleList(page, pageSize,params) {
    let url = `${config.baseUrl}/api/report/lines/users?&page=${page}&reportLineOID=${params}&size=${pageSize}`;
    return httpFetch.get(url)
  },

  //获取报表分配中报表可见范围属性列表
  getVisibleScopeList(lan) {
    let language = lan;
    //后端用 switch 语句写死了 zh_CN
    if(language === 'zh_cn'){
      language = 'zh_CN';
    }
    let url = `${config.baseUrl}/api/lov/reportLine/${language}`;
    return httpFetch.get(url)
  },

  //获取 报表副本 账套列表
  getCopyReportSetOfBookList() {
    let url = `${config.baseUrl}/api/setOfBooks/by/tenant`;
    return httpFetch.get(url)
  },

  ////新增 报表副本 员工信息
  saveEmployeeToCopyReport(params) {
    let url = `${config.baseUrl}/api/report/line/report/obj`;
    return httpFetch.post(url,params)
  },

  //删除 报表副本 员工信息
  deleteEmployeesOfCopyReport(params) {
    let url = `${config.baseUrl}/api/report/line/report/obj`;
    return new Promise(function (resolve) {
      httpFetch.delete(url, params)
        .then(function (res) {
          resolve(res)
        })
        .catch( e => {
          message.error(e.response.data.message);
        });
    })
  },

  //获取 单条 报表副本 可见数据范围  3:已选法人列表   2:已选部门列表  4：已选账套  5:已选公司
  getCopyReportCorporation(reportLineOID,param){
    let url = `${config.baseUrl}/api/report/line/${reportLineOID}/${param}`;
    return httpFetch.get(url)
  }


}
